﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Role_Dict.aspx.cs" Inherits="KPI_SYSTEM.baseData.Role_Dict" %>

<!DOCTYPE html>
<html>
<head runat="server">
    <title></title>
    <style>
        
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <f:PageManager ID="PageManager1" runat="server" />
        <f:Grid ID="Grid1" IsFluid="true" CssClass="blockpanel" ShowBorder="true" ShowHeader="true" EnableCollapse="false"
            runat="server" DataKeyNames="REC_ID,ROLE_NAME" AllowCellEditing="false"  
            DataIDField="REC_ID" Title="角色与权限维护" OnRowCommand="Grid1_RowCommand"  OnPreRowDataBound="Grid1_PreRowDataBound">
            <Toolbars>
                <f:Toolbar ID="Toolbar2" Position="Top" runat="server">
                    <Items>
                        <f:Button ID="btnNew" Text="新增" Icon="Add" EnablePostBack="false" runat="server">
                            <Listeners>
                                <f:Listener Event="click" Handler="onNewButtonClick" />
                            </Listeners>
                        </f:Button>
                        <f:Button ID="btnSyncDingding" Text="同步钉钉" Icon="ArrowDown" EnablePostBack="true" EnableAjax="false"  runat="server" OnClick="btnSyncDingding_Click">
                        </f:Button>
                        <f:Button ID="btnEdit" Text="编辑" Icon="Pencil" EnablePostBack="false" runat="server">
                            <Listeners>
                                <f:Listener Event="click" Handler="onEditButtonClick" />
                            </Listeners>
                        </f:Button>
                        <f:Button ID="btnDelete" Text="删除" Icon="Delete" ConfirmText="确定删除当前数据？" OnClick="btnDelete_Click"
                            runat="server">
                        </f:Button>
                        <f:Button ID="btnAuthority" Text="角色权限设置" Icon="Key" runat="server" OnClick="btnAuthority_Click" >
                            <Listeners>
                                <f:Listener Event="click" Handler="onAuthorityButtonClick" />
                            </Listeners>
                        </f:Button>
                    </Items>
                </f:Toolbar>
            </Toolbars>
            <Columns>
                <f:RenderField Width="200px" ColumnID="ROLE_NAME" DataField="Role_Name"
                    HeaderText="角色名称">
                </f:RenderField>
                <f:RenderField Width="150px" ColumnID="ROLE_CODE" DataField="ROLE_CODE"
                    HeaderText="角色编号">
                </f:RenderField>
                <f:RenderField Width="200px" ColumnID="ROLE_GROUP_NAME" DataField="ROLE_GROUP_NAME"
                    HeaderText="角色组名">
                </f:RenderField>
                <f:RenderField Width="150px" ColumnID="ROLE_GROUP_ID" DataField="ROLE_GROUP_ID"
                    HeaderText="角色组编号">
                </f:RenderField>
                 <f:RenderCheckField  Width="80px" RenderAsStaticField="true" ColumnID="STATUS"  DataField="STATUS"  ExpandUnusedSpace="true" HeaderText="是否启用" />

                <f:LinkButtonField ColumnID="Edit" Width="50px" EnablePostBack="false"
                    Icon="Pencil" />
                <f:LinkButtonField Width="50px" ConfirmText="删除选中行？" ConfirmTarget="Top"
                    CommandName="Delete" Icon="Delete" />
            </Columns>
        </f:Grid>

        <f:Window ID="Window1" Title="弹出窗体" Hidden="true" EnableIFrame="false"
            EnableMaximize="true" Target="Self" EnableResize="true" runat="server"
            IsModal="true" Width="600px">
            <Items>
                <f:SimpleForm ID="SimpleForm1" runat="server" ShowBorder="false" ShowHeader="false" BodyPadding="10px">
                    <Items>
                        <f:HiddenField ID="hfFormID" runat="server"></f:HiddenField>
                        <f:TextBox ID="tbxFormROLE_NAME" ShowRedStar="true" Label="角色名称" Required="true" runat="server">
                        </f:TextBox>
                        <f:TextBox ID="tbxFormROLE_CODE" ShowRedStar="true" Label="角色编号" Required="true" runat="server">
                        </f:TextBox>
                        <f:TextBox ID="tbxFormROLE_GROUP_NAME" ShowRedStar="true" Label="角色组名" Required="true" runat="server">
                        </f:TextBox>
                         <f:TextBox ID="tbxFormROLE_GROUP_ID" ShowRedStar="true" Label="角色编号" Required="true" runat="server">
                        </f:TextBox>
                        <f:CheckBox ID="cbFormSTATUS" Label="是否启用" runat="server">
                        </f:CheckBox>
                        
                    </Items>
                    <Toolbars>
                        <f:Toolbar ID="Toolbar1" Position="Bottom" ToolbarAlign="Right" runat="server">
                            <Items>
                                <f:Button ID="btnSave"
                                    Icon="SystemSave" runat="server" Text="保存数据" ValidateForms="SimpleForm1" OnClick="btnSave_Click">
                                </f:Button>
                            </Items>
                        </f:Toolbar>
                    </Toolbars>
                </f:SimpleForm>
            </Items>
        </f:Window>
        <br />
        <br />
        <br />
        <f:Window ID="Window2" Title="权限设置" Hidden="true" EnableIFrame="false"
            EnableMaximize="true" Target="Self" EnableResize="true" runat="server"
            IsModal="true" Width="600px">
            <Items>
                <f:SimpleForm ID="SimpleForm2" runat="server" ShowBorder="false" ShowHeader="false" BodyPadding="10px">
                    <Items>
                        <f:HiddenField ID="authFormID" runat="server"></f:HiddenField>
                        <f:Tree ID="Tree1" IsFluid="true" CssClass="blockpanel" ShowHeader="true" EnableCollapse="false"
                            Title="菜单列表" runat="server" EnableCheckBox="true" CascadeCheck="true">
                            <%--<Nodes>
                                
                                    <f:TreeNode Text="河南省" Expanded="true">
                                        <f:TreeNode Text="驻马店市" NodeID="zhumadian">
                                            <f:TreeNode Text="遂平县" NodeID="suiping">
                                            </f:TreeNode>
                                            <f:TreeNode Text="西平县" NodeID="xiping">
                                            </f:TreeNode>
                                        </f:TreeNode>
                                        <f:TreeNode Text="漯河市" Checked="true" NodeID="luohe" />
                                    </f:TreeNode>
                                    <f:TreeNode Text="安徽省" Expanded="true" NodeID="anhui">
                                        <f:TreeNode Text="合肥市" NodeID="hefei">
                                        </f:TreeNode>
                                        <f:TreeNode Text="黄山市" NodeID="huangshan">
                                        </f:TreeNode>
                                    </f:TreeNode>
                                
                            </Nodes>--%>
                        </f:Tree>

                    </Items>
                    <Toolbars>
                        <f:Toolbar ID="Toolbar3" Position="Bottom" ToolbarAlign="Right" runat="server">
                            <Items>
                                <f:Button ID="btnSaveAuth"
                                    Icon="SystemSave" runat="server" Text="保存数据" ValidateForms="SimpleForm2" OnClick="btnSaveAuth_Click">
                                </f:Button>
                            </Items>
                        </f:Toolbar>
                    </Toolbars>
                </f:SimpleForm>
            </Items>
        </f:Window>
    </form>
     <script>



         var windowClientID = '<%= Window1.ClientID %>';
         var windowAuthClientID = '<%= Window2.ClientID %>';
        var gridClientID = '<%= Grid1.ClientID %>';
        var btnDeleteClientID = '<%= btnDelete.ClientID %>';
        var btnSaveClientID = '<%= btnSave.ClientID %>';

        var formClientID = '<%= SimpleForm1.ClientID %>';
         var hfFormIDClientID = '<%= hfFormID.ClientID %>';
         var authFormIDClientID = '<%= authFormID.ClientID %>';
         var tbxFormROLE_NAMEClientID = '<%= tbxFormROLE_NAME.ClientID %>';
         var tbxFormROLE_CODEClientID = '<%= tbxFormROLE_CODE.ClientID %>';
         var tbxFormROLE_GROUP_NAMEClientID = '<%= tbxFormROLE_GROUP_NAME.ClientID %>';
         var tbxFormROLE_GROUP_IDClientID = '<%= tbxFormROLE_GROUP_ID.ClientID %>';
        var cbFormSTATUSClientID = '<%= cbFormSTATUS.ClientID %>';
     

        function onNewButtonClick(event) {
            // 重置表单字段
            F(formClientID).reset();
            F(hfFormIDClientID).setValue(null);
            // 弹出窗体
            F(windowClientID).show();
            F(windowClientID).setTitle('新增数据');
        }

        function onEditButtonClick(event) {
            showEditWindow();
         }
         function onAuthorityButtonClick(event) {
             showAuthWindow();
         }


        function showEditWindow(rowId) {
            var grid = F(gridClientID);

            // 如果传入参数为空，则获取当前选中行
            if (!rowId) {
                var selectedRowIds = grid.getSelectedRows();
                if (!selectedRowIds.length) {
                    F.alert('请至少选择一项！');
                    return;
                }

                rowId = selectedRowIds[0];
            }

            
            F(windowClientID).setTitle('编辑数据');

            // 当前行数据
            var rowValue = grid.getRowValue(rowId);

            // 使用当前行数据填充表单字段
            F(hfFormIDClientID).setValue(rowId);
            F(tbxFormROLE_NAMEClientID).setValue(rowValue['ROLE_NAME']);
            F(tbxFormROLE_CODEClientID).setValue(rowValue['ROLE_CODE']);
            F(tbxFormROLE_GROUP_NAMEClientID).setValue(rowValue['ROLE_GROUP_NAME']);
            F(tbxFormROLE_GROUP_IDClientID).setValue(rowValue['ROLE_GROUP_ID']);
            F(cbFormSTATUSClientID).setValue(rowValue['STATUS']);
    

            // 弹出新增窗体
            F(windowClientID).show();
        }
         function showAuthWindow(rowId) {
            var grid = F(gridClientID);

            // 如果传入参数为空，则获取当前选中行
            if (!rowId) {
                var selectedRowIds = grid.getSelectedRows();
                if (!selectedRowIds.length) {
                    F.alert('请至少选择一项！');
                    return;
                }

                rowId = selectedRowIds[0];
            }

            // 当前行数据
            var rowValue = grid.getRowValue(rowId);

            // 使用当前行数据填充表单字段
            F(authFormIDClientID).setValue(rowId);
   
            // 弹出新增窗体
            F(windowAuthClientID).show();
        }
    </script>
 </body>
</html>